using System;
using System.Collections.Generic;
using System.Text;
using Zsa.Emulation.PPU;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

namespace Zsa.Emulation.Mappers
{
    public abstract partial class Mapper
    {


        public void WritePatternImages()
        {
            WritePatternImages(_VideoRomOne);
            if (_VideoRomOne != _VideoRomTwo)
            {
                WritePatternImages(_VideoRomTwo);
            }
        }
        public void WritePatternImages(PatternTable table)
        {

            Image _Image = table.CreateImage();
            string _FileName = 
                Config.NesConfigurationManager.Profiles.PatternTableImageOutputPath +
                Path.GetFileNameWithoutExtension(_Cart.FileInfo.FileName) +
                "." + table.InternalOffset / VideoMemoryConstants.PatternTableByteSize +
                ".bmp";

            if (!File.Exists(_FileName))
            {
                _Image.Save(_FileName, ImageFormat.Bmp);
            }

        }
    }
}
